package com.linhui.rpc.registry;

import java.awt.*;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

/**
 * @author: 临晖
 * @since: 2024-05-10
 *
 * 本地注册
 *
 */
public class LocalRegistry {

    /**
     *
     * 注册信息存储
     *
     */
    private static final Map<String, Class<?>> map = new ConcurrentHashMap<>();


    /**
     *
     * 注册服务
     *
     * @param serviceName
     * @param implClass
     */
    public static void register(String serviceName, Class<?> implClass) {
        map.put(serviceName, implClass);
        System.out.println("有服务注册成功过");
    }

    /**
     *
     * 获取服务
     *
     * @param serviceName
     * @return
     */
    public static Class<?> get(String serviceName) {
        System.out.println("获取服务成功");
        return map.get(serviceName);
    }

    /**
     *
     * 删除服务
     *
     * @param serviceName
     */
    public static void remove(String serviceName) {
        map.remove(serviceName);
        System.out.println("删除服务成功");
    }

}
